/** Control class
*@author Syrings
*@version 2012-03-31 
*Modifications: Controller is used to select the event card randomly, calculate the score that player get
Return all the result to eventWindow for display
Created Method: getSelectedEvent() -> return the selected event to event window
*********************************************/

package event;

import card.EventCard;
import player.*;
import dice.*;

/**
 Event Controller
 */
public class EventController {
	

	/**
	 update the player SE points
	 */
	public void updateSEPoints(Player p, int addSEPoints) {		 
		p.setSEPoint(p.getSEPoint() + addSEPoints);
	}
	

	/**
	 return the mark base on question and answer
	 */
	public int marker(int answer, EventCard pickedEvent){
		int[] temScoreArr = pickedEvent.getScore();
		return temScoreArr[answer-1];
	}
	
	public void RandomEvent(Player player){
		EventCard eventCards = new EventCard();
		EventWindow ew = new EventWindow(player);
		
		RollDice rd = new RollDice(); /**Random Event*/
		int result = rd.roll2(eventCards.getEventArrLength());
		ew.showPickedEventInfo(result);
		int playerAns = ew.getPlayerAns();//demand the answer of player
		ew.showResult(playerAns,player);
	}

	/**
	Return the selected event card to the event window to display
	2012 - 03 - 31 by Syrings
	 */
	public EventCard getSelectedEvent(int diceResult){
		EventCard eventCards = new EventCard();
		return eventCards.getEventArr()[diceResult-1];  /**return the selected event card */
	}
}
